// 配置路由守卫
import router from '@/router'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
/**
 * 路由前置守卫
 */
router.beforeEach((to, from, next) => {
  nprogress.start()

  const jsessionid = localStorage.getItem('JSESSIONID')
  if (!jsessionid && !to.matched.some((record) => record.meta.notAuth)) {
    const casUrl =
      'https://authserver.gdou.edu.cn/authserver/login?service=http://210.38.139.237/fudaoyuan/auth/sso'
    window.location.href = casUrl
  } else {
    next() // 继续导航
    nprogress.done()
  }
  next() // 继续导航
  nprogress.done()
})

/**
 * 后置守卫
 */
router.afterEach(() => {
  nprogress.done()
})
